﻿using JTTD.Domain.Dtos;
using System;

namespace JTTD.Domain.Units
{
    public static class ApiResultUnit
    {

        public static ApiResult<T> Success<T>(T obj)
        {
            return new ApiResult<T>() { IsSuccess = true, Data = obj, Message = "操作成功" };
        }

        public static ApiResult<T> Success<T>()
        {
            return new ApiResult<T>() { IsSuccess = true, Message = "操作成功" };
        }

        public static ApiResult<T> Error<T>(string msg)
        {
            return new ApiResult<T>() { IsSuccess = false, Message = msg };
        }

        public static ApiResult<T> Error<T>(Exception ex)
        {
            return new ApiResult<T>() { IsSuccess = false, Message = ex.Message };
        }
    }
}
